package com.wlr.study.leetcode;

public class LeetCode746 {
    public int minCostClimbingStairs(int[] cost) {
        int n = cost.length;
        int pre = 0, curr = 0;
        for (int i = 2; i <= n; i++) {
            int next = Math.min(curr + cost[i - 1], pre + cost[i - 2]);
            pre = curr;
            curr = next;
        }
        return curr;
    }

    public static void main(String[] args) {
        LeetCode746 leetCode746 = new LeetCode746();
        System.out.println(leetCode746.minCostClimbingStairs(new int[]{1, 100, 1, 1, 1, 100, 1, 1, 100, 1}));
    }
}
